[red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument#17561
Merged
AlexWaygood merged 1 commit intomainfrom Apr 23, 2025
Conversation
AlexWaygood
commented
Apr 22, 2025
Member
Author
There was a problem hiding this comment.
This snapshot honestly feels much too big to me. I only really want to snapshot the new diagnostics for isinstance() and issubclass(); all the reveal_type diagnostics being snapshotted here are pretty noisy. But in order to get a smaller snapshot, I'd have to add another subheading to the protocols.md file, which would break the flow of my literate test suite
Contributor
|
afb9ea0 to
8906bc9
Compare
cc814e6 to
39e7f80
Compare
8906bc9 to
b4e8e97
Compare
39e7f80 to
a3a208f
Compare
b4e8e97 to
1809727
Compare
a3a208f to
cced1b9
Compare
1809727 to
6aa7491
Compare
cced1b9 to
4b29d91
Compare
6aa7491 to
a8fba56
Compare
39538ba to
42c6400
Compare
e96e63f to
7ced9ed
Compare
…ls where a non-runtime-checkable protocol is the second argument
42c6400 to
3db4f2f
Compare
dcreager
added a commit
that referenced
this pull request
Apr 24, 2025
* main: [red-knot] fix collapsing literal and its negation to object (#17605) [red-knot] Add more tests for protocols (#17603) [red-knot] Ban direct instantiations of `Protocol` classes (#17597) [`pyupgrade`] Preserve parenthesis when fixing native literals containing newlines (`UP018`) (#17220) [`airflow`] fix typos (`AIR302`, `AIR312`) (#17574) [red-knot] Special case `@abstractmethod` for function type (#17591) [red-knot] Emit diagnostics for isinstance() and issubclass() calls where a non-runtime-checkable protocol is the second argument (#17561) [red-knot] Infer the members of a protocol class (#17556) [red-knot] Add `FunctionType::to_overloaded` (#17585) [red-knot] Add mdtests for `global` statement (#17563) [syntax-errors] Make duplicate parameter names a semantic error (#17131)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds diagnostics for
isinstance()andissubclass()calls where the second argument is a protocol class that is not declared as runtime-checkable. Using @BurntSushi's new diagnostics infrastructure, it makes these diagnostics beautiful too! Here's a screenshot of what they look like in the terminal:Test Plan
Existing mdtests updated, with new snapshots.